From: Colin Walters Date: Sat, 14 Oct 2017 00:51:39 +0000 (-0400) Subject: lib/deltas: Use pread() instead of lseek()+read() X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~4^2~30^2~46 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=93457071cb5d47c08b60d3244f9632725634010a;p=ostree.git lib/deltas: Use pread() instead of lseek()+read() That's why the syscall was invented, so let's use it. Just noticed while reading the code while working on another patch. Closes: #1270 Approved by: jlebon --- diff --git a/src/libostree/ostree-repo-static-delta-processing.c b/src/libostree/ostree-repo-static-delta-processing.c index 6596da89..fac377ec 100644 --- a/src/libostree/ostree-repo-static-delta-processing.c +++ b/src/libostree/ostree-repo-static-delta-processing.c @@ -719,15 +719,13 @@ dispatch_write (OstreeRepo *repo, { if (state->read_source_fd != -1) { - if (lseek (state->read_source_fd, content_offset, SEEK_SET) == -1) - return glnx_throw_errno_prefix (error, "lseek"); while (content_size > 0) { char buf[4096]; gssize bytes_read; do - bytes_read = read (state->read_source_fd, buf, MIN(sizeof(buf), content_size)); + bytes_read = pread (state->read_source_fd, buf, MIN(sizeof(buf), content_size), content_offset); while (G_UNLIKELY (bytes_read == -1 && errno == EINTR)); if (bytes_read == -1) return glnx_throw_errno_prefix (error, "read");